﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ZhCun.Framework.Common
{
   public class LogHelper
    {
        /// <summary>
        /// 写日志
        /// </summary>
        public static void WriteLog(string str)
        {
            if (!Directory.Exists("ErrLog"))
                Directory.CreateDirectory("ErrLog");
            string logFile = "ErrLog\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            using (StreamWriter sw = new StreamWriter(logFile, true))
            {
                sw.WriteLine("------------------------------" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "------------------------------");
                sw.WriteLine(str);
                sw.WriteLine("-------------------------------------------------------------------------------");
                sw.Close();
            }
        }
        public static void WriteLog(string str,params object[] agrs)
        {
            string r = string.Format(str, agrs);
            WriteLog(r);
        }
    }
}
